#include<stdio.h>
#include<string.h>
#include<ctype.h>
int size=0;
struct info{
	char name[20];
	char pass[20];
	}hash[4000];


int hash_insert(char k[],char l[])
{
	int i=0;
	int j;
	do{
		j=h(k,i);
		if(strcmp(hash[j].name,"")==0)
			{strcpy(hash[j].name,k);
			strcpy(hash[j].pass,l);
			return j;
				}
		else		
			i=i+1;
	}while(i<size);
	return -1;
}

int h(char k[], int i)
{
	int q,l,n=0,x,j;
	q=strlen(k);
	for(j=0;j<q;j++){
	k[j]=tolower(k[j]);
	if(k[j]=='a' || 'e' || 'i' || 'o' || 'u')
	n++;
	}
		return ((n+i)); 

}

int hash_search(char k[], char l[])
{
	int i,j; 
	
	i=0;
	do{
		j=h(k,i);
		if(strcmp(hash[j].name,k)==0) 
			if(strcmp(hash[j].pass,l)==0)
				return j;
		
		i=i+1;
	}while((strcmp(hash[j].name,"")!=0)&&(i<size));
	return -1;
} 

void main()
{	int i,k,c,q,x;
	char name[20],pass[20];
	char name1[20];
	char password[20];
	FILE *f,*fp1;



	fp1=fopen("p.txt","r");
    c=getc(fp1);
    while(c!=EOF)
    {
        if(c=='\n')
        {
            size++; 
	}
            c=getc(fp1);   
     
	}
	size=(20+size);
	
	f=fopen("p.txt","r");
	for(i=0;fscanf(f,"%s %s",name,pass)!= EOF;i++)
		hash_insert(name,pass);
	//for(i=0;i<size;i++)
		//printf("%d %s %s\n",i,hash[i].name,hash[i].pass);
	for(q=0;q<3;q++)
	{
	printf("Enter the username \n");
	scanf(" %s",name1);
	printf("Enter the password \n");
	scanf(" %s",password);
	x=hash_search(name1,password);
	if(x==-1)
	printf("login number %d failed \n",(q+1));
	else{
	printf("Succesful login at login %d \n",(q+1));
	break;
	}
	}
	if(x==-1)
	printf("u have no try left \n");

}
